package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

/**
 * @Description: 用户数据访问
 * @Author: Min-77
 * @Date: 2024/7/27
 **/
@Mapper
public interface UserMapper {

    @Select("select * from user where openid = #{openid}")
    User findByOpenId(String openid);

    /**
     * 插入用户
     * @param user
     */
    @Insert("insert into user values(null,#{openid},#{name},#{phone},#{sex}," +
            "#{idNumber},#{avatar},#{createTime})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    void insert(User user);
}
